##############################################################
# CMakeLists.txt for a ROS package within the low-cost-vision
# build system. 
# 
# Created by Pascal Muller <pascalmuller@gmail.com>, 09-02-2012
# 
# 09-02-2012 Initial version
# 
#############################################################

cmake_minimum_required(VERSION 2.4.6)
# Include all rosbuild macros
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Only add the target to the generated makefile if all external library dependencies 
# are satisfied. 
if(OpenCV_FOUND AND ZBAR_FOUND AND UNICAP_FOUND AND Boost_FOUND)
	# Initialize ROS package to be in our build system. 
	lcv_rospack_init("vision" true true)

	# Add executables as documented by ROS
	rosbuild_add_executable(vision src/main.cpp src/visionNode.cpp src/CrateTracker.cpp)

	# Add dependencies to our libraries and other ROS packages in the same directory as this one. 
	add_dependencies(vision Fiducial unicap_cv_bridge coordinates CameraCalibration)

	# Include and link to libraries
	include_directories(${UNICAP_INCLUDE_DIRS} ${ZBAR_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
	target_link_libraries(vision ${OpenCV_LIBS} ${ZBAR_LIBRARIES} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})


	# Include our libraries, they are all exported in Libraries/LibrariesExport.cmake
	include_directories(${LIB_PCRCTRANSFORMATION_INCLUDE} ${LIB_CAMERACALIBRATION_INCLUDE} ${LIB_UNICAPCVBRIDGE_INCLUDE} ${LIB_FIDUCIAL_INCLUDE})

	# Link target to our libraries
	target_link_libraries(vision Fiducial unicap_cv_bridge coordinates CameraCalibration)
	
	# MUST be called after lcv_rospack_init to clean up after ROSBUILD!
	lcv_rospack_end()

# Oh, let's just warn we omitted an target. 
else(OpenCV_FOUND AND ZBAR_FOUND AND UNICAP_FOUND AND Boost_FOUND)
	lcv_cannot_build(vision, "ROS/vision")
endif(OpenCV_FOUND AND ZBAR_FOUND AND UNICAP_FOUND AND Boost_FOUND)

